[SQL] Derive pushdown predicates from ANSI integral arithmetic - #58705
Draft
tdcmeehan wants to merge 1 commit into
Draft
[SQL] Derive pushdown predicates from ANSI integral arithmetic#58705tdcmeehan wants to merge 1 commit into
tdcmeehan wants to merge 1 commit into
Conversation
tdcmeehan
force-pushed
the
tdcmeehan/integral-predicate-pruning
branch
from
September 10, 2026 19:47
ec23d45 to
04612dc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Add a Catalyst optimizer rule that derives a data-source-pushable predicate from comparisons over ANSI integral addition and subtraction by literals.
For example,
i - 10 > 100gains the conjuncti > 110 OR i < INT_MIN + 10. The second range retains inputs for which the original arithmetic must raise an overflow error. The original comparison remains as a residual predicate and continues to define exact evaluation semantics.The rule supports byte, short, integer, and long arithmetic with literal constants and ordered comparisons or equality. It does not change legacy arithmetic, floating-point arithmetic, multiplication, or arithmetic with a nonliteral operand.
Why are the changes needed?
Arithmetic around a column currently prevents Parquet and other data sources from using their min/max statistics for predicate pruning. The derived predicate exposes safe ranges over the underlying column while preserving ANSI overflow behavior.
Does this PR introduce any user-facing change?
Yes. In ANSI mode, eligible arithmetic filters can now be pushed into data sources for pruning. Query results and overflow errors are unchanged because the original predicate is retained.
How was this patch tested?
Added Catalyst optimizer coverage for ordered comparisons, equality, reversed operands, unsupported expressions, integral range boundaries, and both overflow directions. Added Parquet V2 tests that verify the derived predicate is pushed into the scan and that an overflow input still raises
ARITHMETIC_OVERFLOW.Ran:
Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex 0.147.0